package com.cloud.order.controller;

import com.cloud.order.bean.Order;
import com.cloud.order.properties.OrderProperties;
import com.cloud.order.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Arrays;

/**
 * @author lx
 * @date 2025/11/11
 * @Description
 */
@RefreshScope
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;

    @Resource
    private OrderProperties orderProperties;

    @GetMapping("/creat")
    public Order creatOrder(@RequestParam("userId") Long userId,
                            @RequestParam("productId") Long productId) {
        return orderService.creatOrder(userId, productId);
    }

    @GetMapping("/timeout")
    public String timeout() {
        return orderProperties.getTimeOut() + "__" + orderProperties.getAutoConfirm();
    }
}
